﻿
@{
    ViewBag.Title = "添加地区信息";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@using Mate.Framework.Extensions
@model Mate.Db.Model.Info.mp_district

@section scripts{
    <script src="~/bootstrap/plugins/jquery-validation/dist/jquery.validate.min.js"></script>
    <script src="~/bootstrap/plugins/jquery-validation/dist/additional-methods.min.js"></script>
    <script src="~/bootstrap/scripts/custom/form-validation.js" charset="gbk"></script>

    <script src="~/js/admin.js?v=1.0"></script>
    <script language="javascript" type="text/javascript">
        $(function () {
            var rules = {
                districtname: {
                    required: true
                }

            };
            FormValidation.BasicValidation(rules);

        });
    </script>
}

<ul class="page-breadcrumb breadcrumb">
    <li>
        <a href="@Url.Action("Index","District")">
            商户类型
        </a>
        <i class="fa fa-angle-right"></i>
    </li>
    <li>
        添加地区信息
    </li>
</ul>

<div class="row">
    <div class="col-md-12">
        <div class="portlet-body form">
            <!-- BEGIN FORM-->
            @using (Html.BeginForm("Create", "District", FormMethod.Post, new { @class = "form-horizontal", @id = "form_ff_validation", @novalidate = "novalidate" }))
            {
                <div class="form-body">
                    <div class="form-group">
                        <label class="control-label col-xs-3">
                            父地区
                            <span class="required">*</span>
                        </label>
                        <div class="col-xs-4">
                            <select id="parentid" name="parentid" class="form-control">
                                <option value="0">一级地区</option>
                                @if (ViewBag.DistrictList != null)
                                {
                                    var list = ViewBag.DistrictList as IList<Mate.Dto.Info.DistrictTreeModel>;
                                    var parentList = list.Where(x => x.parentid == 0).ToList();
                                    foreach (var item in parentList)
                                    {
                                        <option value="@(item.id)">@item.districtname</option>
                                        if (item.children.Any())
                                        {
                                            foreach (var item2 in item.children)
                                            {
                                                <option value="@(item2.id)">├── @item2.districtname</option>
                                            }
                                        }
                                    }
                                }
                            </select>
                        </div>
                    </div>
                    @Html.TextFor("名称", "districtname", value: Model.districtname)
                    @Html.RadioFor("状态", "is_open", new List<KeyValuePair<string, string>>()
                                                    {
                                                        new KeyValuePair<string, string>("1","启用"),
                                                        new KeyValuePair<string, string>("2","禁用")
                                                    },selectValue:Model.is_open.ToString())


                </div>
                <div class="form-actions fluid">
                    <div class="col-md-offset-3 col-md-9">
                        <button class="btn green" type="button" onclick="admin.AddSubmit('@Url.Action("Index")')"> 提交 <i class="fa fa-check"></i> </button>
                        <a class="btn default" role="button" href="@Url.Action("Index")"> 返回 <i class="fa fa-reply"></i></a>
                    </div>
                </div>
            }
            <!-- END FORM-->
        </div>
    </div>
    <!-- END VALIDATION STATES-->
</div>
